qui(
    function (require, exports, module) {
        VOD.AccurateFrame = (function () {
            var markedFrameArr = [];
            var adAccurate = {};
            var params = ["fragment-l", "fragment-r", "ad-l", "ad-r"];
            var accurateFrame = {
                'head': '', //打点精确化起始帧
                'end': '', //打点精确化结束帧
                'endSetted': false,
                'headSetted': false
            }
            //搭建js与flash互通的环境
            function thisMovie(movieName) {
                if (navigator.appName.indexOf("Microsoft") != -1) {
                    return window[movieName];
                } else {
                    return document[movieName];
                }
            }

            function doReset() {
                accurateFrame = {
                    'head': '', //打点精确化起始帧
                    'end': '', //打点精确化结束帧
                    'endSetted': false,
                    'headSetted': false
                }
            }


            function accurateStartEndRemove() {
                var frameId = thisMovie('accurateStartEndFrame').get_select_index();

                if (frameId == -1) {
                    frameId = '';
                }
                if (VOD.Util.isTab2Show() || VOD.Util.isTab3Show()) {
                    if ($('.red').parent().find('.p-l').length > 0) {
                        accurateFrame.head = frameId;

                        if (accurateFrame.head){
                            accurateFrame.headSetted = true;
                        }
                    }
                    if ($('.red').parent().find('.p-r').length > 0) {
                        accurateFrame.end = frameId;

                        if (accurateFrame.end){
                            accurateFrame.endSetted = true;
                            VOD.Util.bindFrameData(accurateFrame );
                        }

                    }
                } else {
                    if ($('.red').hasClass('fragment-l')) {
                        accurateFrame.head = frameId;

                        if (accurateFrame.head)
                            accurateFrame.headSetted = true;
                    }
                    else if ($('.red').hasClass('fragment-r')) {
                        accurateFrame.end = frameId;

                        if (accurateFrame.end)
                            accurateFrame.endSetted = true;
                    }
                    else if ($('.red').hasClass('ad-l')) {
                        adAccurate[$('input[name=d_sTime]').val()] = frameId;

                    }
                    else if ($('.red').hasClass('ad-r')) {
                        adAccurate[$('input[name=d_eTime]').val()] = frameId;
                    }
                }

                $('#accurateStartEndOutDiv').css({
                    'left': '-10000px',
                    'top': '-10000px'
                });
            }

            // 打点精确化数据加载
            function accurateStartEndPlay(imgSrc) {
                var analysis = VOD.Dao.getDotData().analysis;
                $('#accurateStartEndOutDiv').css({
                    'left': '0px',
                    'top': '0px'
                });
                thisMovie('accurateStartEndFrame').change_flv_url(analysis + "?file=" + imgSrc + "&from_client=true");
            }

            function getAccurateFrame() {
                return accurateFrame;
            }

            function updateAccurateFrame(options) {
                VOD.Util.updateObjectData(options, accurateFrame)
            }

            function getAdAccurate() {
                return adAccurate;
            }

            // has marked ad will be removed
            function adTipRemove() {
                $('.ad-l').remove();
                $('.ad-r').remove();
            }

            // has marked fragment will be removed
            function fgTipRemove() {
                $('.fragment-l').remove();
                $('.fragment-r').remove();
            }

            function handler_keyCodeQ() {
                var selected = $(".red");
                if (VOD.Util.isTab2Show() || VOD.Util.isTab3Show()) {
                    var lastOption = VOD.NewsHighlight.getLastOption();
                    if (lastOption != null) {
                        var current = parseInt($(".red").parent().find(".pid").text());
                        if (lastOption.st == current || lastOption.et == current || lastOption.pic == current) {
                            console.log("keycodeq," + current);
                            accurateStartEndPlay($("#img-" + current).attr("src"));
                        }
                    }
                } else {
                    $.each(params, function (i, element) {
                        if (selected.hasClass(element)) {
                            accurateStartEndPlay($('.' + element).parent().find("img").attr("src"));
                            return false;
                        }
                    })
                }
            }

            function saveAccurateFrameArr(dataArr) {
                markedFrameArr = dataArr
            }

            function isMarkedFrame(eTime) {
                return markedFrameArr.indexOf(eTime) != -1;
            }
            function readFrameData(frameData){
                accurateFrame = $.extend(true,{},frameData);
            }
            return {
                accurateStartEndPlay: accurateStartEndPlay,
                accurateStartEndRemove: accurateStartEndRemove,
                getAccurateFrame: getAccurateFrame,
                updateAccurateFrame: updateAccurateFrame,
                getAdAccurate: getAdAccurate,
                adTipRemove: adTipRemove,
                fgTipRemove: fgTipRemove,
                handler_keyCodeQ: handler_keyCodeQ,
                doReset: doReset,
                saveAccurateFrameArr: saveAccurateFrameArr,
                isMarkedFrame: isMarkedFrame,
                readFrameData:readFrameData
            }
        })()
    }
);